package com.yaohj.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaohj.dao.UserMapper;
import com.yaohj.entity.MyUserDetail;
import com.yaohj.entity.User;
import com.yaohj.service.UserService;
import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public MyUserDetail getUserByUsername(String username) {
        Wrapper eq = Wrappers.<User>lambdaQuery().eq(User::getUsername, username);
        User user = userMapper.selectOne(eq);
        MyUserDetail myUserDetail = new MyUserDetail();
        myUserDetail.setUsername(user.getUsername());
        myUserDetail.setPassword(user.getPassword());
        return myUserDetail;
    }
}
